<template>
  <el-dialog :visible.sync="open" @close="close" :title="title" width="70%">
    <el-form ref="elForm" size="medium" label-width="100px">
      <el-form-item label="消息类型" prop="levelName">
        <span v-if="data.type == 1">系统消息</span>
        <span v-if="data.type == 2">事件消息</span>
        <span v-if="data.type == 3">处置消息</span>
        <span v-if="data.type == 4">演练情景消息</span>
      </el-form-item>
      <el-form-item label="消息内容" prop="levelContent">
        {{ data.message }}
      </el-form-item>
      <el-form-item label="消息附件" prop="levelContent" v-if="data.comAttaches.length > 0">
        <el-table :data="data.comAttaches" max-height="250" size="mini">
          <el-table-column prop="attachname" label="名称"> </el-table-column>
          <el-table-column prop="attachsize" label="大小"> </el-table-column>
          <el-table-column prop="attachtype" label="类型"> </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="downloadFile(scope.row)">
                下载
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button type="primary" @click="close">确定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import dialogMixin from '../../../mixins/dialogMixin'
import * as MsgApi from '@/api/msg/message';

export default {
  name: 'MessageDetail',
  mixins: [dialogMixin],
  inheritAttrs: false,
  components: {},
  props: [],
  data() {
    return {
      title: '消息详情',
      data: {}
    }

  },
  computed: {},
  watch: {},
  created() { },
  mounted() { },
  methods: {
    showDetail(data) {
      this.data = data;
      this.open = true;
      this.setMsgReaded();
    },
    setMsgReaded() {
      MsgApi.setMessageReaded({ messageId: this.data.messageId, status: 1 }).then(res => {
      })
    },
    downloadFile(row) {
      this.download(
        `com/ComAttach/download/${row.attachid}`,
        {},
        `${row.attachname}.${row.attachtype}`
      );
    },
  }
}

</script>
<style>

</style>
